<?php
/**
 * 客户查重
 * @Author: wjf
 * @Date: 2022-12-01 09:14:08
 */

namespace app\crm\controller\client;

use app\crm\model\client\Duplicat as ClientDuplicat;
use think\Controller;

class Duplicat extends Controller
{
    /**
     * 主页面
     * @Author: wjf
     * @Date: 2022-12-01 09:16:16
     */    
    public function index()
    {
        return $this->fetch();
    }

    /**
     * 遍历数据
     * @Author: wjf
     * @Date: 2022-12-06 11:51:40
     */  
    public function list()
    {
        if ($this->request->param('data')) {
            $aa = $this->request->get('data');
            $arr = [];
            foreach ($aa as $k => $v) {
                if (!$v) {
                    unset($aa[$k]);
                }else {
                    $arr[$k]=$v;
                }
            }
            $page = ($_GET['page'] - 1) * $_GET['limit'];
            $data = ClientDuplicat::where($arr)->where('super_id',1)->where('status',2)->where('classify',1)->select();
            return json(['code' => 0, 'msg' => '遍历', 'count' => count($data), 'data' => $data]);
        }else {
            $page = ($_GET['page'] - 1) * $_GET['limit'];
            $data = ClientDuplicat::limit($page, $_GET['limit'])->where('super_id',1)->where('status',2)->where('classify',1)->select();
            $count = ClientDuplicat::where('super_id',1)->where('status',2)->where('classify',1)->count();
            return json(['code' => 0, 'msg' => '遍历', 'count' => $count, 'data' => $data]);
        }
        
    }  
    
}